package com.crm.system.controller.sys;

import com.crm.common.model.DataResponse;
import com.crm.common.model.DhPageInfo;
import com.crm.common.model.DhResponse;
import com.crm.common.model.Enum.ResponseCodeEnum;
import com.crm.model.entity.sys.permissionManagement.SysInvoiceCompanyInfo;
import com.crm.model.qo.sys.InvoiceCompanyInfoQO;
import com.crm.model.vo.sys.InvoiceCompanyInfoVO;
import com.crm.system.service.sys.SysInvoiceCompanyInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:chaifuyou
 * @Date: 2021/7/27 13:59
 */
@RestController
@RequestMapping("/sysInvoiceCompanyInfo")
@Slf4j
public class SysInvoiceCompanyInfoController {

    @Autowired
    private SysInvoiceCompanyInfoService sysInvoiceCompanyInfoService;

    /**
     * 增加开票公司详情
     * @return
     */
    @PostMapping("/addInvoiceCompanyInfo")
    public DataResponse addInvoiceCompanyInfo(@RequestBody SysInvoiceCompanyInfo invoiceCompanyInfo){
        sysInvoiceCompanyInfoService.addInvoiceCompanyInfo(invoiceCompanyInfo);
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
    }

    /**
     * 修改开票公司详情
     * @return
     */
    @PostMapping("/updateInvoiceCompanyInfo")
    public DataResponse updateInvoiceCompanyInfo(@RequestBody SysInvoiceCompanyInfo invoiceCompanyInfo){
        sysInvoiceCompanyInfoService.updateInvoiceCompanyInfo(invoiceCompanyInfo);
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
    }

    /**
     * 分页查询公司详情列表
     * @param pageIndex
     * @param pageSize
     * @param invoiceCompanyInfoQO
     * @return
     */
    @PostMapping("/selectInvoiceCompanyInfo")
    public DataResponse selectInvoiceCompanyInfo(@RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                 @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                 InvoiceCompanyInfoQO invoiceCompanyInfoQO){
        DhPageInfo<InvoiceCompanyInfoVO> pageVOList = sysInvoiceCompanyInfoService.selectInvoiceCompanyInfo(pageIndex,pageSize,invoiceCompanyInfoQO);
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),pageVOList);
    }

    /**
     * 删除公司详情
     * @param invoiceCompanyInfoId
     * @return
     */
    @PostMapping("/delInvoiceCompanyInfo")
    public DataResponse delInvoiceCompanyInfo(@RequestParam(value = "invoiceCompanyInfoId", required = true) String invoiceCompanyInfoId){
        sysInvoiceCompanyInfoService.delInvoiceCompanyInfo(invoiceCompanyInfoId);
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
    }
}
